package xuhaijia.lanou3g.autohome.find;
//                .-~~~~~~~~~-._       _.-~~~~~~~~~-.
//            __.'              ~.   .~              `.__
//          .'//                  \./                   \\`.
//        .'//            为什么坚持  想一想当初             \\`.
//      .'// .-~"""""""~~~~-._     |     _,-~~~~"""""""~-.  \\`.
//    .'//.-"                 `-.  |  .-'                 "-. \\`.
//  .'//______.============-..   \ | /   ..-============._______\\`.
//.'//____________________________\|/_____________________________\\`.
// 
//                             

import android.content.Context;
import android.graphics.Paint;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import xuhaijia.lanou3g.autohome.R;
import xuhaijia.lanou3g.autohome.base.NetTool;

/**
 * Created by 7 on 16/8/22.
 */
public class RecForMeAdapter extends RecyclerView.Adapter<RecForMeAdapter.RecForMeViewHolder> {
    Context context;
    GuessLikeBean guessLikeBean;

    public RecForMeAdapter(Context context) {
        this.context = context;
    }

    public void setGuessLikeBean(GuessLikeBean guessLikeBean) {
        this.guessLikeBean = guessLikeBean;
    }

    @Override
    public RecForMeViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        View view = LayoutInflater.from(context).inflate(R.layout.item_rv_guesslike, parent, false);
        RecForMeViewHolder recForMeViewHolder = new RecForMeViewHolder(view);
        return recForMeViewHolder;
    }

    @Override
    public void onBindViewHolder(RecForMeViewHolder holder, int position) {
        NetTool mNetTool = new NetTool();
        GuessLikeBean.ResultBean.ModulelistBean modulelistBean = guessLikeBean.getResult().getModulelist().get(1);
        holder.oldPriTv.setText(modulelistBean.getList().get(position).getFctprice());
        holder.oldPriTv.getPaint().setFlags(Paint.STRIKE_THRU_TEXT_FLAG);
        holder.nowPriTv.setText(modulelistBean.getList().get(position).getPrice());
        mNetTool.getImage(modulelistBean.getList().get(position).getLogo(), holder.iv);
        holder.titleTv.setText(modulelistBean.getList().get(position).getTitle());
        holder.desTv.setText(modulelistBean.getList().get(position).getAdinfo());
    }

    @Override
    public int getItemCount() {
        if (guessLikeBean.getResult().getModulelist() == null) {
            return 0;
        }
        return 4;
    }

    public class RecForMeViewHolder extends RecyclerView.ViewHolder {
        ImageView iv;
        TextView titleTv;
        TextView desTv;
        TextView nowPriTv;
        TextView oldPriTv;

        public RecForMeViewHolder(View itemView) {
            super(itemView);
            iv = (ImageView) itemView.findViewById(R.id.item_guesslike_iv);
            titleTv = (TextView) itemView.findViewById(R.id.item_guesslike_title);
            desTv = (TextView) itemView.findViewById(R.id.item_guesslike_des);
            nowPriTv = (TextView) itemView.findViewById(R.id.item_guesslike_pricenow);
            oldPriTv = (TextView) itemView.findViewById(R.id.item_guesslike_priceold);
        }
    }
}